/*
 * @lc app=leetcode.cn id=1170 lang=javascript
 *
 * [1170] 比较字符串最小字母出现频次
 */

// @lc code=start
/**
 * @param {string[]} queries
 * @param {string[]} words
 * @return {number[]}
 */
var numSmallerByFrequency = function(queries, words) {
    let small=function(s){
        let queue=[s[0]]
        for(let i=1;i<s.length;i++){
            if(s[i]<queue[queue.length-1]){
                queue=[s[i]]
            }else if(s[i]==queue[queue.length-1]){
                queue.push(s[i])
            }
        }
        return queue.length
    }
    queries=queries.map((item)=>small(item))
    words=words.map((item)=>small(item))
    console.log(queries,words)
    let num_arr=new Array(11).fill(0)
    for(let i=0;i<words.length;i++){
        num_arr[words[i]]++
    }
    console.log(num_arr)
    let map=new Map()
    let res=[]
    for(let i=0;i<queries.length;i++){
        let sum=0
        if(map.has[queries[i]])sum=map.get(queries[i])
        else{
            for(let j=queries[i]+1;j<=10;j++){
                sum+=num_arr[j]||0
            }
            res.push(sum)
            map.set(queries[i],res)
        }
    }
    return res
};
// @lc code=end

numSmallerByFrequency(["cbd"],["zaaaz"])